﻿@using NC.Service
@model NC.Infrastructure.Domain.Identity.Person

@if (Model != null)
{
    @Html.HiddenFor(model => model.Id)
}

<div class="form-group">
    <label class="control-label col-md-2">昵称</label>
    <div class="col-md-10">
        @Html.EditorFor(model => model.Name, new {htmlAttributes = new {@class = "form-control"}})
        @Html.ValidationMessageFor(model => model.Name, "", new {@class = "text-danger"})
    </div>
</div>


<div class="form-group">
    <label class="control-label col-md-2">真实姓名</label>
    <div class="col-md-10">
        @Html.EditorFor(model => model.TickName, new {htmlAttributes = new {@class = "form-control"}})
        @Html.ValidationMessageFor(model => model.TickName, "", new {@class = "text-danger"})
    </div>
</div>

<div class="form-group">
    <label class="control-label col-md-2">学号</label>
    <div class="col-md-10">
        @Html.EditorFor(model => model.SchoolNumber, new { htmlAttributes = new { @class = "form-control" } })
        @Html.ValidationMessageFor(model => model.SchoolNumber, "", new { @class = "text-danger" })
    </div>
</div>


<div class="form-group">
    <label class="control-label col-md-2">头像</label>
    <div class="col-md-10">
        <div class="input-group">
            <div class="input-group-btn">
                <button type="button" class="btn btn-success" onclick="upFiles('__Image')">上传文件</button>
            </div>
            @Html.EditorFor(model => model.Image, new {htmlAttributes = new {@class = "form-control", id = "__Image"}})
            <div class="input-group-btn">
                <button type="button" class="btn btn-primary" onclick="showImage(this)">浏览</button>
            </div>
        </div>
    </div>
</div>
<div class="modal fade" id="ImageModal">
    <div class="modal-dialog" style="width: 400px;">
        <div class="modal-content">
            <div class="modal-body">
                <img style="width: 400px;" id="ImageContent"/>
            </div>
        </div>
    </div>
</div>
<script id="HeadImage" type="text/plain" style="width:1024px;height:500px;">
</script>


<div class="form-group">
    <label class="control-label col-md-2">入学时间</label>
    <div class="col-md-10">
        <select class="form-control" name="InSchoolTime">
            @{
                var timeDic = EnumDictionary.GetInSchoolTime;
                string queryInTime = Model == null ? "-1" : Model.InSchoolTime.ToString();
                foreach (var time in timeDic)
                {
                    if (time.Key == queryInTime)
                    {
                        <option value="@time.Key" selected="selected">@time.Value</option>
                    }
                    else
                    {   
                        <option value="@time.Key">@time.Value</option>
                    }
                }
            }
        </select>
    </div>
</div>

<div class="form-group">
    <label class="control-label col-md-2">密码</label>
    <div class="col-md-10">
        @Html.EditorFor(model => model.Password, new { htmlAttributes = new { @class = "form-control" } })
        @Html.ValidationMessageFor(model => model.Password, "", new { @class = "text-danger" })
    </div>
</div>

<div class="form-group">
    <label class="control-label col-md-2">角色</label>
    <div class="col-md-10">
        <select class="form-control" name="Role">
            @{
                var roleDic = EnumDictionary.RoleDictionary;
                int queryRole = Model == null ? -1 : (int) Model.Role;
                foreach (var role in roleDic)
                {
                    if (role.Key == queryRole)
                    {
                        <option value="@role.Key" selected="selected">@role.Value</option>
                    }
                    else
                    {
                        <option value="@role.Key">@role.Value</option>
                    }
                }
            }
        </select>
    </div>
</div>

<div class="form-group">
    <label class="control-label col-md-2">自我描述</label>
    <div class="col-md-10">
        @Html.TextAreaFor(model => model.Description, 4, 20, new {@class = "text-danger form-control"})
    </div>
</div>


<script type="text/javascript">
    function showImage(obj) {
        var tag = $(obj).parent().find("input").eq(0);
        $("#ImageContent").attr("src", tag.val());
    }
</script>





